#!/usr/bin/env python
# -*- coding: UTF-8 -*-

'''TODO: More test, proper structure'''

import unittest

from elementary import ElementaryCellularAutomata
from cellular_engine.constants import WORLD_TYPE_DEAD_AROUND


class TestElementary(unittest.TestCase):
    def test_rule_ninety(self):
        elem = ElementaryCellularAutomata(90, '1', 59, WORLD_TYPE_DEAD_AROUND)

        rows = ['00000000000000000000000000000100000000000000000000000000000',
                '00000000000000000000000000001010000000000000000000000000000',
                '00000000000000000000000000010001000000000000000000000000000',
                '00000000000000000000000000101010100000000000000000000000000',
                '00000000000000000000000001000000010000000000000000000000000',
                '00000000000000000000000010100000101000000000000000000000000',
                '00000000000000000000000100010001000100000000000000000000000',
                '00000000000000000000001010101010101010000000000000000000000',
                '00000000000000000000010000000000000001000000000000000000000',
                '00000000000000000000101000000000000010100000000000000000000',
                '00000000000000000001000100000000000100010000000000000000000',
                '00000000000000000010101010000000001010101000000000000000000',
                '00000000000000000100000001000000010000000100000000000000000',
                '00000000000000001010000010100000101000001010000000000000000',
                '00000000000000010001000100010001000100010001000000000000000',
                '00000000000000101010101010101010101010101010100000000000000',
                '00000000000001000000000000000000000000000000010000000000000',
                '00000000000010100000000000000000000000000000101000000000000',
                '00000000000100010000000000000000000000000001000100000000000',
                '00000000001010101000000000000000000000000010101010000000000',
                '00000000010000000100000000000000000000000100000001000000000',
                '00000000101000001010000000000000000000001010000010100000000',
                '00000001000100010001000000000000000000010001000100010000000',
                '00000010101010101010100000000000000000101010101010101000000',
                '00000100000000000000010000000000000001000000000000000100000',
                '00001010000000000000101000000000000010100000000000001010000',
                '00010001000000000001000100000000000100010000000000010001000',
                '00101010100000000010101010000000001010101000000000101010100',
                '01000000010000000100000001000000010000000100000001000000010',
                '10100000101000001010000010100000101000001010000010100000101',
                '00010001000100010001000100010001000100010001000100010001000',
                '00101010101010101010101010101010101010101010101010101010100',
                '01000000000000000000000000000000000000000000000000000000010',
                '10100000000000000000000000000000000000000000000000000000101',
                '00010000000000000000000000000000000000000000000000000001000',
                '00101000000000000000000000000000000000000000000000000010100',
                '01000100000000000000000000000000000000000000000000000100010',
                '10101010000000000000000000000000000000000000000000001010101',
                '00000001000000000000000000000000000000000000000000010000000',
                '00000010100000000000000000000000000000000000000000101000000',
                '00000100010000000000000000000000000000000000000001000100000',
                '00001010101000000000000000000000000000000000000010101010000',
                '00010000000100000000000000000000000000000000000100000001000',
                '00101000001010000000000000000000000000000000001010000010100',
                '01000100010001000000000000000000000000000000010001000100010',
                '10101010101010100000000000000000000000000000101010101010101',
                '00000000000000010000000000000000000000000001000000000000000',
                '00000000000000101000000000000000000000000010100000000000000',
                '00000000000001000100000000000000000000000100010000000000000',
                '00000000000010101010000000000000000000001010101000000000000',
                '00000000000100000001000000000000000000010000000100000000000',
                '00000000001010000010100000000000000000101000001010000000000',
                '00000000010001000100010000000000000001000100010001000000000',
                '00000000101010101010101000000000000010101010101010100000000',
                '00000001000000000000000100000000000100000000000000010000000',
                '00000010100000000000001010000000001010000000000000101000000',
                '00000100010000000000010001000000010001000000000001000100000',
                '00001010101000000000101010100000101010100000000010101010000',
                '00010000000100000001000000010001000000010000000100000001000',
                '00101000001010000010100000101010100000101000001010000010100',
                '01000100010001000100010001000000010001000100010001000100010',
                '10101010101010101010101010100000101010101010101010101010101',
                '00000000000000000000000000010001000000000000000000000000000',
                '00000000000000000000000000101010100000000000000000000000000',
                '00000000000000000000000001000000010000000000000000000000000',
                '00000000000000000000000010100000101000000000000000000000000',
                '00000000000000000000000100010001000100000000000000000000000',
                '00000000000000000000001010101010101010000000000000000000000',
                '00000000000000000000010000000000000001000000000000000000000',
                '00000000000000000000101000000000000010100000000000000000000',
                '00000000000000000001000100000000000100010000000000000000000',
                '00000000000000000010101010000000001010101000000000000000000',
                '00000000000000000100000001000000010000000100000000000000000',
                '00000000000000001010000010100000101000001010000000000000000',
                '00000000000000010001000100010001000100010001000000000000000',
                '00000000000000101010101010101010101010101010100000000000000',
                '00000000000001000000000000000000000000000000010000000000000',
                '00000000000010100000000000000000000000000000101000000000000',
                '00000000000100010000000000000000000000000001000100000000000',
                '00000000001010101000000000000000000000000010101010000000000',
                '00000000010000000100000000000000000000000100000001000000000',
                '00000000101000001010000000000000000000001010000010100000000',
                '00000001000100010001000000000000000000010001000100010000000',
                '00000010101010101010100000000000000000101010101010101000000',
                '00000100000000000000010000000000000001000000000000000100000',
                '00001010000000000000101000000000000010100000000000001010000',
                '00010001000000000001000100000000000100010000000000010001000',
                '00101010100000000010101010000000001010101000000000101010100',
                '01000000010000000100000001000000010000000100000001000000010',
                '10100000101000001010000010100000101000001010000010100000101',
                '00010001000100010001000100010001000100010001000100010001000',
                '00101010101010101010101010101010101010101010101010101010100',
                '01000000000000000000000000000000000000000000000000000000010',
                '10100000000000000000000000000000000000000000000000000000101',
                '00010000000000000000000000000000000000000000000000000001000',
                '00101000000000000000000000000000000000000000000000000010100',
                '01000100000000000000000000000000000000000000000000000100010',
                '10101010000000000000000000000000000000000000000000001010101',
                '00000001000000000000000000000000000000000000000000010000000',
                '00000010100000000000000000000000000000000000000000101000000']

        for row in rows:
            self.assertEqual(row, elem.rows[-1],
                             'Error at generation %i' % elem.generation)
            elem.game_loop()

if __name__ == '__main__':
    unittest.main()
